package com.kwm.Aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

//@Aspect
@Component
@Slf4j

public class EmpAscept {

//    方法一
//    @Pointcut("execution(* com.kwm.Service.impl.EmpServiceimpl.*(..))")
    //方法二
    @Pointcut("@annotation(com.kwm.Aop.Log)")
    public void at(){}

    @Before("at()")
    public void befor(){
        log.info("通知前");
    }

    @Around("at()")
    public Object EmpForm(ProceedingJoinPoint joinPoint) throws Throwable {
        // 获取通知类名
        String name = joinPoint.getTarget().getClass().getName();

        //获取方法标签

        Signature signature = joinPoint.getSignature();

        // 获取方法名
        String name1 = joinPoint.getSignature().getName();

        // 获取 方法参数
        Object[] args = joinPoint.getArgs();


        Object result = joinPoint.proceed();

        log.info("通知");

        return result;
    }


}
